/*----------------------------------------------------------------------------*\
| /gamemode/cl_scoreboard.lua          | end-of-round scoreboard system  | CLI |
\*----------------------------------------------------------------------------*/

function Avatars( Ply )
	local Frame = vgui.Create( "Frame" )
	local Avatar = vgui.Create( "AvatarImage", Frame )
	Avatar:SetPlayer( Ply )
	Avatar:SetPos( HUD_X + (3*HUD_P) + 16, HUD_Y + HUD_H - (3*HUD_P) - 80 )
	Avatar:SetSize( 64, 64 )
end
concommand.Add( "testvgui", Avatars )


lab			= {}
lab.text	= ""
lab.amt		= ""
lab.x		= ""
lab.each	= ""
lab.eq		= ""
lab.num		= ""

for a,b in pairs(scoredata) do
	lab.text = lab.text .. a .. "\n"
	lab.amt = lab.amt .. "\n"
	lab.x = lab.x .. "\n"
	lab.each = lab.each .. "\n"
	lab.eq = lab.eq .. "\n"
	lab.num = lab.num .. "\n"
	
	for c,d in pairs(b) do
		lab.text = lab.text .. d.t .. "\n"
		lab.amt = lab.amt .. "??????\n"
		lab.x = lab.x .. "x\n"
		lab.each = lab.each .. "??????\n"
		lab.eq = lab.eq .. "=\n"
		lab.num = lab.num .. "??????\n"
	end
	
	lab.text = lab.text .. "\n"
	lab.amt = lab.amt .. "\n"
	lab.x = lab.x .. "\n"
	lab.each = lab.each .. "\n"
	lab.eq = lab.eq .. "\n"
	lab.num = lab.num .. "\n"
end

sb_x=((ScrW()-640)/2)+4
sb_y=((ScrH()-480)/2)+4

// Fullscreen blur effect
fullscreen = vgui.Create("DPanel")
	fullscreen:SetVisible(false)
	fullscreen:SetWide(ScrW())
	fullscreen:SetTall(ScrH())
	fullscreen:SetPos(0,0)
	fullscreen:SetPaintBackground(false)
	//fullscreen:Center()
	
	// Scoreboard container
	scoreboard = vgui.Create("DPanel",fullscreen)
		scoreboard:SetWide(ScrW())
		scoreboard:SetTall(ScrH())
		scoreboard:SetVisible(false)
		scoreboard:SetPaintBackground(false)
		
		// "My Scores" window
		myscores = vgui.Create("DFrame",scoreboard)
			myscores:SetTitle("My Score")
			myscores:SetWide(228)
			myscores:SetTall(472)
			myscores:SetPos(sb_x+4,sb_y+4)
			myscores:SetDraggable(false)
			myscores:ShowCloseButton(false)
			myscores:SetBackgroundBlur(true)
			
			// Labels
			myscorelist_text = vgui.Create("DLabel", myscores)
				myscorelist_text:SetText(lab.text)
				myscorelist_text:SizeToContents()
				myscorelist_text:SetPos(4,24)
				
			// Amount for each
			myscorelist_amt = vgui.Create("DLabel", myscores)
				myscorelist_amt:SetText(lab.amt)
				myscorelist_amt:SizeToContents()
				myscorelist_amt:SetPos(90,24)
			myscores:MakePopup()
			
			// Times symbol
			myscorelist_x = vgui.Create("DLabel", myscores)
				myscorelist_x:SetText(lab.x)
				myscorelist_x:SizeToContents()
				myscorelist_x:SetPos(128,24)
			
			// Value for each
			myscorelist_each = vgui.Create("DLabel", myscores)
				myscorelist_each:SetText(lab.each)
				myscorelist_each:SizeToContents()
				myscorelist_each:SetPos(140,24)
			myscores:MakePopup()
			
			// Equals symbol
			myscorelist_eq = vgui.Create("DLabel", myscores)
				myscorelist_eq:SetText(lab.eq)
				myscorelist_eq:SizeToContents()
				myscorelist_eq:SetPos(177,24)
				
			// Subtotal for each
			myscorelist_num = vgui.Create("DLabel", myscores)
				myscorelist_num:SetText(lab.num)
				myscorelist_num:SizeToContents()
				myscorelist_num:SetPos(191,24)
			myscores:MakePopup()
		
		// "Others' Scores" window
		otherscores = vgui.Create("DFrame",scoreboard)
			otherscores:SetTitle("Others' Scores")
			otherscores:SetWide(400)
			otherscores:SetTall(472)
			otherscores:SetPos(sb_x+236,sb_y+4)
			otherscores:SetDraggable(false)
			otherscores:ShowCloseButton(false)
			otherscores:MakePopup()

function ScoreboardOn( ply )
	fullscreen:SetVisible(true)
	scoreboard:SetVisible(true)
end
concommand.Add( "scoreboardon", ScoreboardOn )
function ScoreboardOff( ply )
	fullscreen:SetVisible(false)
	scoreboard:SetVisible(false)
end
concommand.Add( "scoreboardoff", ScoreboardOff )
